###########################################
#
#  Eaty The Alien
#
#  An incredible intergalactic adventure.
#
#  Use ASWD to move Eaty.
#  Use E to activate Eaty's Magic Neck.
#
#  Icons in the lower right corner indicate
#  when you are standing on a special area.
#  Find all three parts of Eaty's phone,
#  activate it at the "C" marker and
#  be on the marker with 4 arrows by
#  the time the countdown ends.
#  Watch your life force- every step you
#  take on this inhospitable planet drains
#  your health. Consume Skittles(tm)
#  candies and drain the essence of flowers
#  to stay alive.
#
###########################################

:alias px        vd
:alias py        vc
:alias pdir      vb
:alias pframe    va
:alias has-item  v9 #(in pits)
:alias has-enemy v9 #(on ground)
:alias is-dead   v8
:alias roomindex v7
:alias pitindex  v6
:alias inventory v5
:alias timer     v4

# v0-v3 are reserved as temporaries.

:const FACE_LEFT    0
:const FACE_RIGHT 128
:const KEY_LEFT     7
:const KEY_RIGHT    9
:const KEY_UP       5
:const KEY_DOWN     8
:const KEY_NECK     6

:const ITEM_X      12
:const ITEM_Y      32
:const START_LIFE   2
:const ROSE_LIFE    3
:const PIECES_LIFE  1
:const PART_1       8
:const PART_2      16
:const PART_3      32
:const ALL_PARTS   56

:const NOTHING      0
:const ROSE         1 # (in pit)
:const PIECES       1 # (on ground)
:const NECK_ESP     2

:const CALL_SHIP    4
:const GO_SHIP      5

:const TIMER_LO    20
:const TIMER_HI     8

###########################################
#
#  Main Logic
#
###########################################

: main
	loop
		draw-title

		hires
		clear
		randomize-loot

		v0 := START_LIFE
		v1 := 0
		i  := life-force-hi
		save v1

		px        := 60
		py        := 16
		pdir      :=  0
		pframe    :=  0
		has-item  :=  0
		is-dead   :=  0
		roomindex :=  4
		inventory :=  0
		timer     :=  0
	
		draw-room
		draw-hud
		draw-eaty
		
		main-loop
	again

: draw-title
	lores
	clear
	v0 := 0
	v1 := 0
	v2 := 32
	i  := title-screen
	loop
		sprite v0 v1 0
		v0 += 16
		i  += v2
		if v0 == 64 then v1 += 16
		if v0 == 64 then v0 := 0
		if v1 != 32 then
	again
	v0 := 48
	v1 := 22
	v2 := KEY_NECK
	i  := fingat
	loop
		sprite v0 v1 1
		if v2 -key then
	again
: wait-release
	loop
		if v2 key then
	again
;

: draw-end
	# display image
	lores
	clear
	v0 := 16
	v1 :=  4
	sprite v0 v1 0
	v0 := 32
	i  += v0
	sprite v0 v1 0

	# show score
	v1 := 22
	v2 := -7
	i := life-force-hi
	draw-pair
	i := life-force-lo
	draw-pair

	v0 := key
	jump wait-release

: main-loop

	spawn-room
	loop
		if has-enemy == 1 then draw-enemy

		draw-eaty
		draw-hud
		save-position
		move-overworld
		dec-timer
		if is-dead != 0 then return		

		draw-eaty
		if vf != 0 then overworld-collide
		if has-enemy == 1 then move-enemy
		if has-enemy == 1 then draw-enemy
		draw-hud

		sync
	again
;

###########################################
#
#  Utility Routines
#
###########################################

: animate-magic-neck
	i := eaty-neck
	i += pdir
	v0 := 32
	v1 := 0
	loop
		sprite px py 0
		sync
		sprite px py 0
		i  += v0
		v1 += 1
		if v1 == 3 then buzzer := v1
		if v1 != 4 then
	again
;

: animate-death
	i := eaty-walk
	sprite px py 0
	sync
	sprite px py 0
	i := die-0
	sprite px py 0
	sync
	sprite px py 0
	i := die-1
	sprite px py 0
	sync
	v0 := key
	is-dead := 1
	i := game-over
	jump draw-end

: move-right
	if pdir == FACE_RIGHT begin
		px += 2
	else
		pdir := FACE_RIGHT
		pframe := -32
	end
;

: move-left
	if pdir == FACE_LEFT begin
		px += -2
	else
		pdir := FACE_LEFT
		pframe := -32
	end
;

: draw-eaty
	i := eaty-walk
	i += pdir
	i += pframe
	sprite px py 0
;

: next-frame
	pframe += 32
	v0     := 127
	pframe &= v0
	dec-life
;

: sync
	loop
		vf := delay
		if vf != 0 then
	again
	vf := 5
	delay := vf
;

: wait
	loop
		vf := delay
		if vf != 0 then
	again
	vf := 1
	delay := vf
;

: position-temp 0x00 0x00 0x00

: save-position
	v0 := px
	v1 := py
	v2 := pdir
	i  := position-temp
	save v2
;

: restore-position
	i := position-temp
	load v2
	px     := v0
	py     := v1
	pdir   := v2
;

: iplus16
	v0 <<= v0
	v0 <<= v0
	v0 <<= v0
	v0 <<= v0
	i += v0
;

: bounce-out
	loop
		if vf == 0 then return
		draw-eaty
		px := random 127
		py := random  63
		px += 2
		if px > 110 then px += -63
		py += 1
		if py > 47 then py += -32
		draw-eaty
	again
;

###########################################
#
#  Enemies
#
###########################################

: enemy-data   00 00

: spawn-room
	has-enemy := 0
	if roomindex == 1 then jump spawn-enemy
	if roomindex == 3 then jump spawn-enemy
	if timer     == 0 then return
	if roomindex != 4 then return
: spawn-enemy
	has-enemy := 1
	v0 := random 63
	v0 += 32
	v1 :=  0
	i  := enemy-data
	save v1
;

: draw-enemy
	i := enemy-data
	load v1
	i := copter
	sprite v0 v1 0
;

: move-enemy
	i := enemy-data
	load v1
	vf := random 0b11
	if vf == 0 then v0 += -3
	if vf == 1 then v0 +=  3
	vf := 127
	v0 &= vf
	v1 += 1
	vf := 63
	v1 &= vf
	i := enemy-data
	save v1

	# check player overlap
	px += 128
	py +=  64
	v0 += 128
	v1 +=  64
	v0 += -16  if px < v0 then jump cleanup
	v0 +=  32  if px > v0 then jump cleanup
	v1 += -16  if py < v1 then jump cleanup
	v1 +=  32  if py > v1 then jump cleanup
	dec-life
	dec-life
	dec-life
	dec-life
	vf := 5
	buzzer := vf

: cleanup
	px += -128
	py +=  -64
;

###########################################
#
#  Hud and Life Force
#
###########################################

: timer-lo         00
: life-force-hi    00
: life-force-lo    00
: life-force-temp  0x00
: life-force-tens  0x00
: life-force-ones  0x00

: draw-hud
	i  := heart
	v1 :=  2
	v2 := -7
	sprite v1 v2 5
	v1 += 6
	i := life-force-hi
	draw-pair
	i := life-force-lo
	draw-pair

	v1 := -10
	i := part-tiles
	i += inventory
	if timer != 0 then i := bighex timer
	sprite v1 v1 8

	if roomindex > 4 then return
	loot-px
	v1 := -19
	v2 := -10
	i  := blank
	if v0 == GO_SHIP   then i := go-ship
	if v0 == CALL_SHIP then i := call-ship
	if v0 == NECK_ESP  then i := neck-esp
	if v0 == PIECES    then i := pieces
	sprite v1 v2 8
;

: draw-part
	v0 := inventory
	v0 &= vf
	if v0 != 0 then sprite v1 v1 8
;

: draw-pair
	load v0
	i := life-force-temp
	bcd v0
	i := life-force-tens
	draw-digit
	i := life-force-ones
	draw-digit
;

: draw-digit
	load v0
	i := hex v0
	sprite v1 v2 5
	v1 += 5
;

: dec-life
	i := life-force-hi
	load v1
	vf := 1
	v1 -= vf
	if vf != 1 begin
		v0 += -1
		if v0 == -1 begin
			animate-death
			return
		else
			v1 := 99
		end
	end
	i := life-force-hi
	save v1
;

: dec-timer
	if timer == 0 then return
	i := timer-lo
	load v0
	if v0 == 0 begin
		if timer == 1 begin
			timer := 0
			loot-px
			if v0 != GO_SHIP then return
			is-dead := 1
			i := victory
			jump draw-end
		else
			timer += -1
			v0 := TIMER_LO
		end
	end
	v0 += -1
	i := timer-lo
	save v0
;

: give-life # takes argument (in hundreds) in vf
	i := life-force-hi
	load v0
	v0 += vf
	i := life-force-hi
	save v0
;

###########################################
#
#  Overworld Logic
#
###########################################

: draw-room
	v2 := 0
	loop
		this-room
		# col stride is 4, data stride is 2, so shift right.
		v0 >>= v2
		i += v0
		load v1
		i := overworld-tiles
		iplus16
		sprite v2 v1 15
		v2 += 4
		if v2 != 128 then
	again
;

: scroll-room-left
	roomindex += 1
	if roomindex == 5 then roomindex := 0
	v2 := 124
	v3 := 0
	loop
		this-room
		i += v3
		load v1
		i := overworld-tiles
		iplus16
		scroll-left
		sprite v2 v1 15
		wait
		v3 += 2
		if v3 != 64 then
	again
	px := 1
	spawn-room
;

: scroll-room-right
	roomindex += -1
	if roomindex == -1 then roomindex := 4
	v2 := 0
	v3 := 62
	loop
		this-room
		i += v3
		load v1
		i := overworld-tiles
		iplus16
		scroll-right
		sprite v2 v1 15
		wait
		v3 += -2
		if v3 != -2 then
	again
	px := 111
	spawn-room
;

: move-overworld
	v0 := KEY_NECK if v0 key begin
		animate-magic-neck
		loot-px
		if v0 == NECK_ESP begin
			# neck esp reveals all nearby items in pits
			reveal-pit-items
			return
		end
		if v0 == PIECES begin
			# pieces are a single-use health pickup
			vf := PIECES_LIFE give-life
			v0 := 0
			v1 >>= px # px / 16
			v1 >>= v1
			v1 >>= v1
			v1 >>= v1
			loot-set
			return
		end
		if v0 == CALL_SHIP begin
			# you gotta do this to end the game
			if inventory == ALL_PARTS then timer := TIMER_HI
			v0 := 0
			v1 >>= px # px / 16
			v1 >>= v1
			v1 >>= v1
			v1 >>= v1
			loot-set
			try-place-call
		end
		return
	end

	# track whether any keys are held down
	v1 := 0	

	if py != 1 begin
		v0 := KEY_UP if v0 key begin
			v1 := 1
			py += -1
		end
	end
	if py != 47 begin
		v0 := KEY_DOWN if v0 key begin
			v1 := 1
			py += 1
		end
	end
	v0 := KEY_LEFT if v0 key begin
		v1 := 1
		move-left
		if px < 2 then scroll-room-right
	end
	v0 := KEY_RIGHT if v0 key begin
		v1 := 1
		move-right
		if px > 110 then scroll-room-left
	end

	# if no keys were pressed, snap to neutral pose:
	if v1 == 0 then pframe := 0
	if v1 != 0 then next-frame
;

###########################################
#
#  Neck ESP
#
###########################################

: reveal-pit-items
	sparkle-pit-items
	sync
	sparkle-pit-items
;

: sparkle-pit-items
	v2 := 0 # byte offset to room data
	loop
		this-room
		i += v2
		load v1
		# v0 sprite index
		# v1 y-coord
		
		# make sure it's a pit
		if v0 == 1 begin		
			v3 := v1
			v3 += 4
			v1 >>= v2
			v1 >>= v1
			v1 >>= v1 # v2 / 8
			loot-here
			# v0 loot
			# v3 y-coord
		
			# make sure an item is down there
			if v0 != 0 begin
				v1 += 4
				i := sparkle
				v2 <<= v2
				v2 += 3
				sprite v2 v3 8
				v2 += -3
				v2 >>= v2
			end
		end

		v2 += 8
		if v2 != 64 then
	again
;

###########################################
#
#  Overworld Collision
#
###########################################

: overworld-collide
	py += 64

	this-room
	v3 := 0
	loop
		load v1
		# v0 - slice sprite typecode
		# v1 - slice Y position
		# v3 - slice X position

		# ignore blank columns entirely
		if v0 == 0 then jump overworld-continue
		v1 += 64
	
		# is eaty vertically within the slice?
		v1 += 15
		if py > v1 then jump overworld-continue
		v1 += -30
		if py < v1 then jump overworld-continue

		# is eaty horizontally within the slice?
		v2 := v3
		v2 +=  4
		if px > v2 then jump overworld-continue
		v2 += -16
		if px < v2 then jump overworld-continue

		# perform an action based on sprite id
		v0 += -1
		v0 >>= v0
		v0 >>= v0
		if v0 == 0 begin
			v3 >>= v3
			v3 >>= v3
			v3 >>= v3
			pitindex >>= v3
			fall-pit
		else
			# tree
			draw-eaty
			restore-position
			draw-eaty
			bounce-out
		end
		return

: overworld-continue
		v3 += 4
		if v3 != 128 then
	again
;

###########################################
#
#  Pit Items
#
###########################################

: draw-item
	v0 := ITEM_X
	v1 := ITEM_Y
	if has-item == ROSE begin
		i := rose-0
		sprite v0 v1 0
		return
	end
	i := blank
	if has-item == PART_1 then i := part-1
	if has-item == PART_2 then i := part-2
	if has-item == PART_3 then i := part-3
	sprite v0 v1 8
;

: near-item # return result in v0
	v0 := 0
	if has-item == 0 then return
	if px < 36 then v0 := 1
;

: wilt-rose
	v0 := ITEM_X
	v1 := ITEM_Y
	v2 := 0
	i  := rose-0
	loop
		sprite v0 v1 0
		vf := 32
		i  += vf
		sprite v0 v1 0
		sync
		v2 += 1
		if v2 != 4 then
	again
	vf := ROSE_LIFE give-life
;

: take-item
	if has-item == ROSE begin
		wilt-rose
	else
		draw-item
		inventory |= has-item
	end
	has-item := 0
	v0 := 0
	v1 := pitindex
	roomindex += -5
	loot-set
	roomindex += 5
;

###########################################
#
#  Pit Logic
#
###########################################

: draw-pit
	i := pit-wall
	v1 := 0
	v0 := -8
	loop
		sprite v0 v1 0
		v1 += 16
		if v1 != 64 then
	again

	i := pit-ground
	v0 := 8
	v1 := 48
	loop
		sprite v0 v1 0
		v0 += 16
		if v0 != 120 then
	again

	v1 := 33
	i  := pit-lf
	v0 := 8
	sprite v0 v1 15
	i  := pit-rt
	v0 := -16
	sprite v0 v1 15

	draw-item
;

: move-pit
	# track whether any keys are held down
	v1 := 0
	v0 := KEY_LEFT if v0 key begin
		v1 := 1
		if px != 24 then move-left
	end
	v0 := KEY_RIGHT if v0 key begin
		v1 := 1
		if px != 100 then move-right
	end

	# if no keys were pressed, snap to neutral pose:
	if v1 == 0 then pframe := 0
	if v1 != 0 then next-frame
;

: fly-pit
	draw-eaty
	animate-magic-neck
	draw-eaty
	loop
		draw-eaty
		py += -2
		draw-eaty
		sync
		if py != 0 then
	again
	clear

	restore-position
	roomindex += -5
	draw-room
	draw-eaty
	bounce-out
;

: fall-pit
	v1 := pitindex
	loot-here
	has-item := v0

	roomindex += 5
	clear
	draw-pit
	px     := 60
	py     :=  0
	pdir   := FACE_LEFT
	pframe := 0
	i      := eaty-walk

	draw-eaty
	loop
		draw-eaty
		py += 2
		draw-eaty
		sync
		if py != 32 then
	again

	draw-hud
	loop
		draw-eaty
		draw-hud

		move-pit
		dec-timer
		draw-eaty

		v0 := KEY_NECK if v0 key begin
			near-item
			if v0 == 1 begin
				draw-eaty
				animate-magic-neck
				draw-eaty
				take-item
			else
				fly-pit
				return
			end
		end

		draw-hud
		sync

		if is-dead == 0 then
	again
;

###########################################
#
#  Randomized Loot
#
###########################################

: randomize-loot
	# distribute common/nonvital items:

	v1 := 0 # room-0 offset
	v2 := 0 # loot-data offset
	loop
		# pits   can be 0-1
		# ground can be 0-3
		is-pit
		v3 := random 0b11
		if v0 == 1 then v3 := random 0b01
		v0 := v3
		i := loot-data
		i += v2
		save v0

		v1 += 8
		v2 += 1
		if v2 != 32 then
	again
	
	# place CALL_SHIP on ground
	try-place-call

	# place parts on pits
	v4 := PART_1
	try-place-part
	v4 := PART_2
	try-place-part
	v4 := PART_3
	try-place-part
;

: try-place-call
	v3 := random 31
	is-v3-pit
	if v0 == 1 then jump try-place-call
	i := loot-data
	i += v3
	load v0
	if v0 > 3 then jump try-place-call
	i := loot-data
	i += v3
	v0 := CALL_SHIP
	#:breakpoint call-place
	save v0
;

: try-place-part
	v3 := random 31
	is-v3-pit
	if v0 != 1 then jump try-place-part
	i := loot-data
	i += v3
	load v0
	if v0 > 3 then jump try-place-part
	i := loot-data
	i += v3
	v0 := v4
	#:breakpoint part-place
	save v0
;

: is-v3-pit
	v1 <<= v3
	v1 <<= v1
	v1 <<= v1 # offset * 8
: is-pit
	# takes offset in v1,
	# leaves 1 in v0 if it's a pit.
	i := room-0
	i += v1
	load v0
	if v0 != 1 then v0 := 0
;

###########################################
#
#  Level Data
#
###########################################

# loot definitions are 8 bytes per room.
: loot-data
	0 0 0 0 0 0 0 0 # room 0
	0 0 0 0 0 0 0 0 # room 1
	0 0 0 0 0 0 0 0 # room 2
	0 0 0 0 0 0 0 0 # room 3
	0 0 5 0 0 0 0 0 # room 4

: loot-px
	# leaves result in v0
	v1 >>= px
	v1 >>= v1
	v1 >>= v1
	v1 >>= v1 # px / 16
: loot-here
	# takes column in v1, leaves result in v0
	v0 <<= roomindex
	v0 <<= v0
	v0 <<= v0 # roomindex * 8
	i  := loot-data
	i  += v0
	i  += v1
	load v0
;

: loot-set
	# takes column in v1, value in v0
	i := loot-data
	i += v1
	v1 <<= roomindex
	v1 <<= v1
	v1 <<= v1 # roomindex * 8
	i += v1
	save v0
;

# rooms are 64 bytes each.
# each room is a series of packed pairs:
# <sprite index, y coord>
: room-0
	 0  0    0  0    0  0    0  0
	 1  8    2  8    3  8    4  8 #
	 0  0    0  0    0  0    0  0
	 1 40    2 40    3 40    4 40 #
	 0  0    0  0    0  0    0  0
	 1  8    2  8    3  8    4  8 #
	 0  0    0  0    0  0    0  0
	 0  0    0  0    0  0    0  0
: room-1
	 0  0    0  0    0  0    0  0
	 5  6    6  6    7  6    8  6 #
	 0  0    0  0    0  0    0  0
	 5 40    6 40    7 40    8 40 #
	 5 32    6 32    7 32    8 32 #
	 0  0    0  0    0  0    0  0
	 5 20    6 20    7 20    8 20 #
	 0  0    0  0    0  0    0  0
: room-2
	 0  0    0  0    0  0    0  0
	 1 39    2 40    3 41    4 42 #
	 1  6    2  5    3  4    4  3 #
	 0  0    0  0    0  0    0  0
	 0  0    0  0    0  0    0  0
	 1  3    2  4    3  5    4  6 #
	 1 42    2 41    3 40    4 39 #
	 0  0    0  0    0  0    0  0
: room-3
	 0  0    0  0    0  0    0  0
	 0  0    0  0    0  0    0  0
	 5 30    6 30    7 30    8 30 #
	 5 40    6 40    7 40    8 40 #
	 5 40    6 40    7 40    8 40 #
	 5  6    6  6    7  6    8  6 #
	 1 42    2 41    3 40    4 39 #
	 0  0    0  0    0  0    0  0
: room-4
	 0  0    0  0    0  0    0  0
	 0  0    0  0    0  0    0  0
	 0  0    0  0    0  0    0  0
	 0  0    0  0    0  0    0  0
	 5 40    6 40    7 40    8 40 #
	 0  0    0  0    0  0    0  0
	 0  0    0  0    0  0    0  0
	 0  0    0  0    0  0    0  0

: this-room
	v0 <<= roomindex
	v0 <<= v0
	jump0 room-table

: room-table
	i := room-0 ;
	i := room-1 ;
	i := room-2 ;
	i := room-3 ;
	i := room-4 ;

###########################################
#
#  Graphics
#
###########################################

# hud tiles
: heart       0x50 0xF8 0xF8 0x70 0x20
: call-ship   0x1C 0x3C 0x7C 0x70 0x70 0x7C 0x3C 0x1C
: go-ship     0xE7 0xC3 0xA5 0x18 0x18 0xA5 0xC3 0xE7 
: pieces      0x30 0x48 0x4E 0x39 0x39 0x4E 0x48 0x30
: neck-esp    0x08 0x04 0x12 0x4A 0x4A 0x12 0x04 0x08
: sparkle     0x00 0x08 0x01 0x00 0x48 0x00 0x01 0x10

: part-tiles  0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 # 0 - nothing
: part-1      0x7E 0xFF 0x81 0x00 0x00 0x00 0x00 0x00 # 1 - 1
: part-2      0x00 0x00 0x24 0x3C 0x3C 0x24 0x00 0x00 # 2 - 2
	          0x7E 0xFF 0xA5 0x3C 0x3C 0x24 0x00 0x00 # 3 - 1,2
: part-3      0x00 0x00 0x00 0x00 0x18 0x18 0x7E 0xFF # 4 - 3
	          0x7E 0xFF 0x81 0x00 0x18 0x18 0x7E 0xFF # 5 - 1,3
	          0x00 0x00 0x24 0x3C 0x24 0x3C 0x7E 0xFF # 6 - 2,3
	          0x7E 0xFF 0xA5 0x3C 0x24 0x3C 0x7E 0xFF # 7 - 1,2,3

: fingat      0xC0

# overworld tiles
# packed into 4 pixel wide vertical slices,
# so I can draw as I scroll horizontally.
: overworld-tiles
: blank       0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 # 0
: pit-0       0x10 0x70 0xF0 0xC0 0xB0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0x70 0x10 0x00 # 1
: pit-1       0xF0 0xF0 0x00 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0x00 # 2
: pit-2       0xF0 0xF0 0x00 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0x00 # 3
: pit-3       0x80 0xE0 0xF0 0x30 0xD0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xF0 0xE0 0x80 0x00 # 4
: tree-0      0x00 0x00 0x00 0x00 0x10 0x30 0xF0 0x70 0x30 0x60 0xF0 0x70 0x50 0x00 0x00 0x00 # 5
: tree-1      0x10 0x20 0x60 0xB0 0x60 0xF0 0xE0 0x50 0xF0 0xB0 0x70 0xF0 0xB0 0x30 0x30 0x00 # 6
: tree-2      0x80 0x40 0x20 0x10 0x00 0x50 0x30 0x30 0x70 0xB0 0x70 0xF0 0xD0 0xC0 0xC0 0x00 # 7
: tree-3      0x00 0x00 0x00 0x00 0x80 0xC0 0x70 0xE0 0xC0 0xE0 0x50 0xE0 0xC0 0x00 0x00 0x00 # 8

# pit background tiles
: pit-ground  0xF7 0xF7 0x7F 0x7F 0xED 0xED
: pit-wall    0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
              0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
              0xFF 0xFF 0xFF 0xFF
: pit-lf      0x80 0x80 0xC0 0xC0 0xC0 0xE0 0xE0 0xE0 0xF0 0xF0 0xF0 0xF8 0xF8 0xFC 0xFE 
: pit-rt      0x01 0x01 0x03 0x03 0x03 0x07 0x07 0x07 0x0F 0x0F 0x0F 0x1F 0x1F 0x3F 0x7F

# rose wilting animation
: rose-0
	0x00 0x00 0x00 0x00 0x05 0xE0 0x05 0xE0
	0x05 0xE0 0x06 0xE0 0x03 0xC0 0x01 0x18
	0x19 0xA8 0x14 0xD0 0x0A 0x60 0x07 0xC0
	0x01 0x80 0x03 0x00 0x03 0x00 0x01 0x80	
: rose-1
	0x00 0x00 0x00 0x00 0x01 0x00 0x0B 0x70
	0x0B 0xE0 0x0D 0xE0 0x07 0xC0 0x01 0x00
	0x01 0x80 0x1C 0xF0 0x22 0x68 0x1F 0xD8
	0x01 0x80 0x03 0x00 0x03 0x00 0x01 0x80
: rose-2
	0x00 0x00 0x00 0x00 0x00 0x00 0x02 0x40
	0x03 0xE0 0x0D 0xF0 0x07 0xF0 0x0F 0x30
	0x01 0x80 0x00 0xE0 0x06 0x70 0x0F 0xD0
	0x0D 0xB0 0x0B 0x20 0x03 0x00 0x01 0x80
: rose-3
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0x01 0x20 0x13 0xC0 0x0B 0xF0
	0x1B 0xB0 0x0A 0xC0 0x00 0x60 0x03 0xC0
	0x05 0xA0 0x0F 0x30 0x0B 0x70 0x01 0xA0
: rose-4
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0x01 0x00 0x03 0xC0 0x03 0xC0
	0x03 0xC0 0x03 0xC0 0x00 0x60 0x01 0xC0
	0x01 0x80 0x03 0x00 0x03 0x70 0x0D 0xB8

# eaty wal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0x38 0x00 0x3F 0xE0 0x13 0xFC 0x1B 0xF4
	0x1F 0xF0 0x1F 0xF0 0x18 0xB0 0x1E 0x38
: neck-r-1
	0x00 0x00 0x0F 0xF8 0x0F 0xFC 0x1F 0x58
	0x1F 0xB8 0x39 0xFC 0x38 0x54 0x38 0x00
	0x38 0x00 0x1F 0xE0 0x13 0xFC 0x1B 0xF4
	0x1F 0xF0 0x1F 0xF0 0x18 0xB0 0x1E 0x38
: neck-r-2
	0x0F 0xFC 0x0F 0x18 0x1F 0x58 0x1F 0x18
	0x19 0xFC 0x38 0x54 0x38 0x00 0x38 0x00
	0x18 0x00 0x1F 0xE0 0x13 0xFC 0x1B 0xF4
	0x1F 0xF0 0x1F 0xF0 0x18 0xB0 0x1E 0x38
: neck-r-3
	0x00 0x00 0x0F 0xF8 0x0F 0xFC 0x1F 0x58
	0x1F 0xB8 0x39 0xFC 0x38 0x54 0x38 0x00
	0x38 0x00 0x1F 0xE0 0x13 0xFC 0x1B 0xF4
	0x1F 0xF0 0x1F 0xF0 0x18 0xB0 0x1E 0x38

# death animation
: die-0
	0x00 0x00 0x03 0xC0 0x00 0x00 0x1F 0xF0
	0x3F 0xF8 0x3F 0xF8 0x1B 0xF8 0x3F 0x9C
	0x2A 0x1C 0x00 0x1C 0x07 0xFC 0x0F 0xE8
	0x1F 0xD8 0x2F 0xD8 0x0F 0xF8 0x1D 0x78
: die-1
	0x00 0x00 0x03 0xC0 0x04 0x20 0x03 0xC0
	0x00 0x00 0x1F 0xF0 0x3F 0xF8 0x3F 0xF8
	0x3F 0xFC 0x3F 0x9C 0x2A 0x7C 0x0F 0xFC
	0x0F 0xE8 0x0F 0xE8 0x0F 0xF8 0x1F 0xF8

: copter
	0xF8 0x1F 0x20 0x04 0xF9 0x1F 0xF9 0x1F 
	0x89 0x11 0x73 0xCE 0x17 0xE8 0x0D 0xB0 
	0x07 0xE0 0x06 0x60 0xFB 0xDF 0x23 0xC4 
	0xFC 0x3F 0xF8 0x1F 0x88 0x11 0x70 0x0E 

: title-screen
	0x00 0x00 0x00 0xF8 0x07 0xF8 0x07 0xC0
	0x07 0x00 0x07 0xB9 0x03 0xFB 0x03 0xE3
	0x03 0x81 0x03 0xC5 0x01 0xDE 0x01 0xFE
	0x01 0xFC 0x00 0xF0 0x00 0x80 0x00 0x00
	0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x4C
	0x03 0x6C 0x9F 0xB8 0xD6 0x18 0x66 0x08
	0xF3 0x0C 0xB3 0x0C 0x93 0x80 0xC0 0x00
	0x00 0x75 0x00 0x27 0x00 0x25 0x00 0x25
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x70 0xC8 0x61 0x28 0x41 0xE8 0x71 0x2E
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0xBB 0x40 0xB2 0xC0 0xA2 0x40 0xBA 0x40
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x00
	0x00 0x01 0x00 0x03 0x00 0x01 0x00 0x03
	0x00 0x01 0x00 0x01 0x00 0x01 0x00 0x00
	0x00 0x00 0x00 0x00 0x12 0x00 0x0F 0xFF
	0x35 0x00 0xC0 0x00 0xD0 0x00 0x82 0xC2
	0x83 0xCB 0xD0 0x1C 0x94 0x00 0xDF 0xAA
	0xAE 0xEB 0xD6 0x3E 0xEB 0x00 0xF5 0x00
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0xC0 0x03 0x20 0x1C 0x21 0x23 0xC0 0xCC
	0xC0 0x90 0x21 0xA0 0x61 0x3E 0xC3 0x9D
	0x01 0x41 0x00 0xEA 0x00 0xFE 0x00 0xB8
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0xE0 0x00 0x20 0x00 0xC0 0x00
	0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
	0x00 0x00 0x80 0x00 0x00 0x00 0x00 0x00

: game-over
	0x1E 0x79 0x3E 0xFD 0x30 0xCD 0x36 0xFD
	0x32 0xCD 0x3E 0xCD 0x1E 0xCD 0x00 0x00
	0x0E 0x63 0x1F 0x63 0x1B 0x63 0x1B 0x63
	0x1B 0x77 0x1F 0x3E 0x0E 0x1C 0x00 0x00
	0x83 0x7C 0xC7 0x7C 0xEF 0x60 0xBB 0x78
	0x93 0x60 0x83 0x7C 0x83 0x7C 0x00 0x00
	0x7D 0xF0 0x7D 0xF8 0x61 0x98 0x79 0xF0
	0x61 0x98 0x7D 0x98 0x7D 0x98 0x00 0x00

: victory
	0x00 0x32 0x00 0x4A 0xEE 0x7A 0xEE 0x4A
	0xEE 0x4B 0xEE 0x00 0xEE 0x9B 0xFE 0xA1
	0x7C 0xA1 0x7C 0xA1 0x38 0xA1 0x38 0xA1
	0x10 0x99 0x00 0x00 0x00 0x00 0x00 0x00
	0x2E 0x90 0x28 0xD0 0x2E 0xB0 0x28 0xB0
	0xAE 0x90 0x00 0x00 0xBB 0x36 0x2A 0xB6
	0x2A 0xB6 0x2B 0x36 0x2A 0xB6 0x2A 0xBE
	0x3A 0x9E 0x00 0x06 0x00 0x3E 0x00 0x3C